package com.zf.shuashua.ui.home.search;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseViewHolder;
import com.meis.base.mei.adapter.MeiBaseAdapter;
import com.zf.shuashua.R;
import com.zf.shuashua.api.Store;
import com.zf.shuashua.bean.comment.UserEntity;

import java.util.List;

public class SearchUserListAdapter extends MeiBaseAdapter<UserEntity> {
    private TextView btFans;

    public SearchUserListAdapter(int layoutResId, @Nullable List<UserEntity> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final UserEntity item) {
        helper.setText(R.id.tvName, item.name + "")
                .setText(R.id.tvSign, item.signature)
                .addOnClickListener(R.id.tvIsFocus);
        Glide.with(mContext)
                .load(item.avatar)
                .circleCrop()
                .into((ImageView) helper.getView(R.id.imgAvatar));
        btFans = helper.getView(R.id.tvIsFocus);
        String currentUserId = Store.getInstance().getuserId();
        if (!TextUtils.isEmpty(currentUserId) && currentUserId.equals(item.id + "")) {
            btFans.setVisibility(View.GONE);
            return;
        }
        if (item.follow_status == 0) {
            btFans.setText("关注");
            btFans.setBackgroundResource(R.drawable.fans_off);
        } else {
            btFans.setText(item.follow_status_text);
            btFans.setBackgroundResource(R.drawable.fans_no);
        }
    }
}